package edu.scau.divineplace.util;


import com.google.common.base.Preconditions;
import edu.scau.divineplace.entity.query.PageQuery;

/**
 * @Author: x1aolone
 * @Date: 2020/12/29 21:43
 */
public class PageQueryUtil {

    private static final Integer ALL_CURRENT_PAGE = -1;
    private static final Integer ALL_PAGE_SIZE = -1;


    public static void fillAllIfAbsent (PageQuery pageQuery) {
        Preconditions.checkNotNull(pageQuery);
        if (pageQuery.getCurrentPage() == null) {
            pageQuery.setCurrentPage(ALL_CURRENT_PAGE);
        }
        if (pageQuery.getPageSize() == null) {
            pageQuery.setPageSize(ALL_PAGE_SIZE);
        }
    }

}
